import {
  API_URL
} from '../../env.js'
import service from "./service.js"

/**
* request.js是对基层网络请求的封装
*/
export function postlink(url, data) {
  console.log('API_URL', API_URL)
  return new Promise((resolve, reject) => {
      service.request({
          url: API_URL + url,
          method: "post",
          headers: {
              "Content-Type": "application/json;charset=UTF-8",
              "token": uni.getStorageSync('token') || "",
              "x-access-token": localStorage.getItem('token') || ''
          },
          data
      }).then((ok) => {
          resolve(ok)
      }).catch((err) => {
          reject(err)
      })
  })
}
export function getlink(url, params) {
  return new Promise((resolve, reject) => {
      service.request({
          url: API_URL + url,
          headers: {
              "Content-Type": "application/json;charset=UTF-8",
              "token": uni.getStorageSync('token') || "",
              "x-access-token": localStorage.getItem('token') || '',
      //24065d77-3e3c-4a5b-bbb9-eae922476f13
              // "x-access-token":"5e569ae0-122d-40c5-ade8-a5f8994b202d"
          },
          method: "get",
          params
      }).then((ok) => {
          resolve(ok)
      }).catch((err) => {
          reject(err)
      })
  })
}